-
Notifications
You must be signed in to change notification settings - Fork 21
refactor: cleanup test for api-client #4420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
4c59006
to
2f9c86d
Compare
jest.spyOn(client.api.auth, 'postLogout').mockReturnValue(Promise.reject(testError)); | ||
jest.spyOn(client, 'disconnect').mockReturnValue(); | ||
jest.spyOn(client['accessTokenStore'], 'delete').mockReturnValue(Promise.resolve(undefined)); | ||
jest.spyOn(client['logger'], 'warn').mockReturnValue(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe makes sense to destructure spyOn from jest just to have a few less characters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't have strong opinion on this, I'd like to keep it this way. I don't think character count is a very useful metrics
jest.spyOn(client.api.auth, 'postLogout'); | ||
jest.spyOn(client, 'disconnect').mockReturnValue(); | ||
jest.spyOn(client['accessTokenStore'], 'delete').mockReturnValue(Promise.resolve(undefined)); | ||
jest.spyOn(client['logger'], 'warn').mockReturnValue(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const websocketClient = new WebSocketClient('url', fakeHttpClient); | ||
const onOpenSpy = spyOn<any>(websocketClient, 'onOpen').and.callThrough(); | ||
const websocketClient = new WebSocketClient('ws://url', fakeHttpClient); | ||
const onOpenSpy = jest.spyOn(websocketClient as any, 'onOpen'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe destructuring makes sense in this file also since its called many times. also wondering about all these as any
blocks if they can be improved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they sadly cannot be improved easily since the test is relying on mocking private methods :/
This would be too much of a hustle trying to fix this, so I'm restoring to the original behavior
packages/api-client/src/conversation/ConversationAPI/ConversationAPI.test.ts
Outdated
Show resolved
Hide resolved
…ionAPI.test.ts Co-authored-by: Timothy LeBon <[email protected]>
This removes the dependencies to webpack/karma related process that are slowing down quite a lot.
We need generate a pristine tsc compiled library that doesn't require building for a browser.